package src.Note.Note8;

import java.util.Arrays;

/**
 * @Author： 20192315裴湘瑞
 * @Date: 2020/11/15 15:56
 * @Version: 1.0
 * @Target：数组元素反转
 * @Requirement：不能使用新数组
 */
public class  Note8 {
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5};
        printArray(array);
        System.out.println("=================");
        int[] result = returnArray(1,2,3,4,5);
        System.out.println("数组元素数据和为：" + result[0]);
        System.out.println("数组元素平均数为：" + result[1]);
        System.out.println("=================");
        System.out.println("数组反转为：");
        for (int min = 0,max = array.length - 1; min < max; min++, max--) {
            int temp = array[min];
            array[min] = array[max];
            array[max] = temp;
        }
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
        System.out.println("=================");
        System.out.println(Arrays.toString(array));
    }
    public static void printArray(int[] array) {
        System.out.println("printArray方法的地址值是：" + array);
        System.out.println("原数组为：");
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
        System.out.println("=================");
        System.out.println(Arrays.toString(array));
    }

    public static int[] returnArray(int a, int b, int c, int d, int e) {
        int sum = a + b + c + d + e;
        int avg = sum / 5;
        int[] arrayB = { sum, avg };
        return arrayB;
    }
}
